package com.market.manager.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.market.dao.PictureDao;
import com.market.domain.Picture;
import com.market.manager.PictureManager;

@Service("pictureManager")
public class PictureManagerImpl extends
		GenericManagerImpl<PictureDao, Picture, Long> implements PictureManager {

	@Autowired
	public void setDao(PictureDao pictureDao) {
		this.dao = pictureDao;
	}

	public Picture fetchOne(Long id) {
		return this.dao.findById(id);
	}

	public Picture fetchOne(Picture picture) {
		if (picture != null && picture.getIsNew() == false) {
			return this.fetchOne(picture.getId());
		} else {
			return picture; // If picture is new or null, doesn't need to fetch
							// from database;
		}
	}

	public List<Picture> fetchAllHomePagePictures() {
		return this.dao.findAllHomePagePictures();
	}

	public List<Picture> fetchAllRecycled() {		
		return this.dao.findAllRecycled();
	}

	public List<Picture> fetchAllNotRecycled() {		
		return this.dao.findAllNotRecycled();
	}

	public List<Picture> fetchPictureByYear(String year) {		
		return this.dao.findPictureByYear(year);
	}	
	
}
